package service;

import java.util.List;

import bean.Address;
import bean.AddressRowMapper;
import bean.GoodsImg;
import bean.GoodsImgRowMapper;
import bean.OrderInfo;
import bean.OrderInfoRowMapper;
import bean.User;
import bean.UserRowMapper;
import common.BaseDAO;

public class AdminOrderDAO extends BaseDAO{
	//获取所有订单记录
		public int listAll(){
			String sql="select count(*) from order_info where order_status<>4 order by orderid";
			return this.getCount(sql);
		}
			
		public List<OrderInfo> queryAllOrders(int pagesize,int viewPage){
			int offset=pagesize*(viewPage-1);
				String sql = "select * from order_info where order_status<>4 order by orderid limit ?,?";
				return this.query(sql, new OrderInfoRowMapper(),offset,pagesize);
		}
		
		//通过收货地址ID查收货地址
		public List<Address> getAddress(int addressid) {
			String sql="select * from address_info where addressid=?";
			return this.query(sql, new AddressRowMapper(), addressid);
		}
		//通过userID查会员
		public List<User> getUser(int userid) {
			String sql="select * from user_info where userid=?";
			return this.query(sql, new UserRowMapper(), userid);
		}
		
		//通过id删除订单
		public void delete(String orderid) {
			String sql="update order_info set order_status=4 where orderid=?";
			this.update(sql,orderid);	
	}
		///通过id给订单发货
		public void sendGood(String orderid) {
			String sql="update order_info set post_status=1 where order_status<>4 and orderid=?";
			this.update(sql,orderid);	
	}

}
